import { uniRequset } from '@/utils/request'
import type { BannerType } from '@/types/banner'
import type { categoryItem, categoryType, HotRecommenditemType, ProductType } from '@/types/home'
// uniapp对axios的支持不太好，所以需要调用自己封装的uniRequset,我在其中做了拦截器的配置
export const getBannerListAPI = () => {
  return uniRequset<BannerType[]>({
    url: '/banner/get_banner_list/',
    method: 'GET',
  })
}

export const getCategoryListAPI = () => {
  return uniRequset<categoryType>({
    url: '/category/get_category_list/',
    method: 'GET',
  })
}

export const getHotRecommendListAPI = () => {
  return uniRequset<HotRecommenditemType<ProductType>[]>({
    url: '/goods/get_recommend_products/',
    method: 'GET',
  })
}

export const getGuessListAPI = (page: number) => {
  return uniRequset<ProductType[]>({
    url: '/goods/product/get_guss_like_products/',
    method: 'GET',
    // 在小程序中，不管是get还是post请求参数都在data中
    data: { page: page },
  })
}
